﻿$(function() {

    JSUtility.url = "../../Handler/AjaxHandle.ashx";
    JSUtility.param.ClassName = "OA.Bll.Project.ProjectProblemPresenter";
    autoResize({ dataGrid: '#Grid', callback: Initlist });
    //alert(IframeHelper.getParentValue('ContractsID'));
    JSUtility.window_edit = $('#Add').window({
        iconCls: 'icon-add',
        zIndex: 1000,
        draggable: true,
        resizable: false,
        shadow: true,
        inline: true,
        modal: true,
        title: '集成项目故障统计',
        collapsible: false,
        minimizable: false,
        maximizable: false,
        closable: true,
        width: 600,
        closed: true,
        onOpen: function() {
            $('#Add').parent().css("left", "10%");
            $('#Add').parent().next().css("left", "10%");
            $('#Add').parent().next().css("top", "5%");
            $('#Add').parent().css("top", "5%");
        }
    });
    JSUtility.window_edit_title = "集成项目故障统计";
    JSUtility.window_edit_form = $("#Add").find("form");    
    ComboboxInitial();
    $('#Add').show();
});

function ComboboxInitial() {

    //var ProductModel= JSHelper.comboboxData2("#ProductModel", '20');
    //JSHelper.comboboxData2("#ProductModular", '');
    $("#ProductModel").combobox({
        url: '../../Handler/AjaxComboboxData.ashx?typeId=20',
        valueField: 'id',
        textField: 'text'
    }).combobox({ onSelect: function(record) {
        $("#ProductModular").combobox({
            url: "../../Handler/AjaxComboboxData.ashx?typeId=20&parentId=" + record.id,
            valueField: "id",
            textField: "text"
        });
    }
    });
    JSHelper.comboboxData2("#HardwareProblems", '21');
    JSHelper.comboboxData2("#SoftwareProblems", '22');
    if (!self.parent.projectInfoManager) {
        JSHelper.combotreeProject('ProjectId', "../../Handler/AjaxProjectTreeHandle.ashx?internaltype=1", 135);
    }
}

function Initlist(size) {
    if (self.parent.projectInfoManager) {
        JSUtility.param.Options["ProjectId"] = self.parent.parent.project_id;
        JSUtility.replenish = function() {
            $("#ProjectId").val(self.parent.parent.project_id);
        };
        $("#ProjectId").attr("readonly", "readonly");
    }
    JSUtility.param.Method = "Search";
    JSUtility.grid = $('#Grid').datagrid({
        tilte: '集成项目故障统计',
        iconCls: 'icon-save',
        width: size.width,
        height: size.height,
        pageSize: Math.round(size.height / 25),
        pageList: [Math.round(size.height / 25)],
        nowrap: true,
        striped: true,
        url: JSUtility.url,
        queryParams: { "json": $.toJSON(JSUtility.param) },
        sortName: 'Id',
        sortOrder: 'desc',
        idField: 'Id',
        frozenColumns: [[{ title: '编号', field: 'Id', width: 50, sortable: true}]],
        columns: [[
                            { title: '项目编号', field: 'ProjectId', width: 100 },
                            { title: '项目名称', field: 'ProjectName', width: 100 },
        //                            { title: '项目名称', field: 'ProjectName', width: 100 },
                            {title: '设备名称', field: 'DeviceName', width: 120 },
                            { title: '设备数量', field: 'DeviceCount', width: 50 },
                            { title: '故障发生位置', field: 'FaultPosition', width: 100 },
                            { title: '故障模块', field: 'ProductModel', width: 100 },
                            { title: '故障子模块', field: 'ProductModular', width: 100 },
                            { title: '发生时间', field: 'HappenTime', width: 100 },
                            { title: '故障分类', field: 'FaultClass', width: 100 },
                            { title: '处理结果', field: 'Result', width: 100 },
                            { title: '问题关闭情况', field: 'State', width: 80 }

                        ]],
        pagination: true,
        rownumbers: true,
        singleSelect: true,
        toolbar: [
                    {
                        text: '添加',
                        iconCls: 'icon-add',
                        handler: JSUtility.add
                    }, '-',
                    {
                        text: '修改',
                        iconCls: 'icon-edit',
                        handler: function() {
                            JSUtility.update();
                            JSHelper.conbotreeUpdateProject("ProjectId");
                        }
                    }, '-',
                    {
                        text: '删除',
                        iconCls: 'icon-remove',
                        handler: JSUtility.del
                    }, '-',
                    {
                        text: '查询',
                        iconCls: 'icon-search',
                        handler: JSUtility.search
                    }
                  ]
    });
}